"""
装饰器：由@组成的一种 能对函数添加功能的方式，且在未修改原函数代码的前提下
"""
import time


# 方式1
# def print_test():
#     print("这里是Python的课程，请认真学习")
#
#
# def show_run_time(func):
#     t_start = time.time()
#     func()
#     t_stop = time.time()
#     print("耗时:", t_stop - t_start)
#
#
# show_run_time(print_test)


# 方式2

# def print_test():
#     print("这里是Python的课程，请认真学习")
#
#
# def show_run_time(func):
#     def call_func():
#         t_start = time.time()
#         func()
#         t_stop = time.time()
#         print("耗时:", t_stop - t_start)
#
#     return call_func
#
#
# aaa = show_run_time(print_test)
# aaa()

# 方式3
#
# def print_test():
#     print("这里是Python的课程，请认真学习")
#
#
# def show_run_time(func):
#     def call_func():
#         t_start = time.time()
#         func()
#         t_stop = time.time()
#         print("耗时:", t_stop - t_start)
#
#     return call_func
#
#
# print_test = show_run_time(print_test)
# print_test()


# 方式4

def show_run_time(func):
    def call_func():
        t_start = time.time()
        func()
        t_stop = time.time()
        print("耗时:", t_stop - t_start)

    return call_func


@show_run_time
def print_test():
    print("这里是Python的课程，请认真学习")


# print_test = show_run_time(print_test)
print_test()
